Raw BPF Bindings
================
[![Maven Central](https://img.shields.io/maven-central/v/me.bechberger/rawbpf)](https://search.maven.org/artifact/me.bechberger/rawbpf)

The raw BPF bindings generated by [jextract](https://github.com/openjdk/jextract) for libbpf on 64-bit systems
and the generation code wrapping jextract.
This library is used by [hello-ebpf](../hello-ebpf) to access the BPF library.

These bindings are regularly updated and published on Maven Central:

```xml
<dependency>
    <groupId>me.bechberger</groupId>
    <artifactId>rawbpf</artifactId>
    <version>0.1.4</version>
</dependency>
```

The bindings include the headers listed in [misc/bpf_headers.h](misc/bpf_headers.h).

Usage
-----
The bindings are located in the `me.bechberger.ebpf.bpf.raw` package,
with the main classes being `Lib` and `Lib_1`.

To load the libbpf, there is a helper class `LibraryLoader`:

- `LibraryLoader.load()` loads the library from the classpath and exits the JVM if it fails
- `LibraryLoader.isInstalled()` checks if the library is installed on the system

Requirements
------------
- Java 22
- Linux 64-bit
- libbpf (install `libbpf-dev` on Ubuntu or Debian)
  - e.g. `apt install libbpf-dev linux-tools-common linux-tools-$(uname -r)` on Ubuntu or Debian


Build
-----

Additional Requirements:

- Python 3.8+
- clang (for [jextract](https://github.com/openjdk/jextract))
- Maven 3.6.3 (or newer to build the project)

Build the project with `mvn package`.

Release
-------

Be sure to update the version both in the README and the pom and then run `mvn clean deploy`.

License
-------
Apache 2.0, Copyright 2023 SAP SE or an SAP affiliate company, Johannes Bechberger and contributors